<?php
namespace app\api\controller\pgb;

class Pgb extends Base
{

    /**
     * 第三方同步用户
     */
    public function userAdd(){
        $d = $this->post();
        $rule = [
            'phone' => 'require',
            'username' => 'require',
            'partner'=>'require'
        ];
        $msg = [
            'phone.require' => '电话不能为空',
            'username.require' => '用户名不能为空',
            'partner.require'=>'商户号不能为空'
        ];
        check($rule, $msg, $d);
        $rs = m("appThree","c")->addUser($d['partner'],$d['username'], $d['phone']);
        if($rs){
            suc();
        }else{
            err(m("appThree","c")->getError());
        }
    }

    /**
     * 添加余额
     */
    public function addMoeny(){
        $d = $this->post();
        $rule = [
            'phone' => 'require|mobile',
            'money' => 'require|number',
            'partner'=>'require'
        ];
        $msg = [
            'phone.require' => '电话不能为空',
            'money.require' => '金额不能为空',
            'partner.require'=>'商户号不能为空'
        ];
        check($rule, $msg, $d);
        $rs = s("appThree","c")->recharge($d['partner'],$d['phone'], $d['money']);
        if($rs){
            suc();
        }else{
            err(s("appThree","c")->getError());
        }

    }

    /**
     * 积分充值
     */
    public function addPoint(){
        $d = $this->post();
        $rule = [
            'phone' => 'require|mobile',
            'point' => 'require|number',
            'partner'=>'require'
        ];
        $msg = [
            'phone.require' => '电话不能为空',
            'point.require' => '积分不能为空',
            'partner.require'=>'商户号不能为空'
        ];
        check($rule, $msg, $d);
        $rs = s("appThree","c")->rechargeJf($d['partner'],$d['phone'], $d['point']);
        if($rs){
            suc();
        }else{
            err(s("appThree","c")->getError());
        }
    }


}

?>
